//
//  UserBuiesTableViewController.m
//  EasyBuy
//
//  Created by apple on 12-10-18.
//  Copyright (c) 2012年 shen donghao. All rights reserved.
//

#import "UserBuiesTableViewController.h"
#import "UserAllBuyInfoData.h"
#import "UserALLBuyHeadTableViewCell.h"
#import "UserAllBuyMiddleTableViewCell.h"
#import "UserAllBuyInfoTableViewCell.h"

@interface UserBuiesTableViewController ()

@end

@implementation UserBuiesTableViewController

@synthesize objectId;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.view.backgroundColor = [UIColor whiteColor];
        UserAllBuyInfoData *userAllBuyInfoData = [[UserAllBuyInfoData alloc] init];
//        self.title = userAllBuyInfoData.userName;
        self.title = @"清风吻过";
        [userAllBuyInfoData release];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    [self setTabelView];
    
}

- (void)setTabelView{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:tableView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    // Return the number of rows in the section.
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 50;
    }
    if (indexPath.row == 1) {
        return 30;
    }
    if (indexPath.row == 2) {
        return 100;
    }
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *headCellIdentifier = @"headCell";
    static NSString *midlleCellIdentifier = @"middleCell";
    static NSString *buyInfoCellIdentifier = @"buyInfoCell";

    if (indexPath.row == 0) {
        UserALLBuyHeadTableViewCell *headcell = [tableView dequeueReusableCellWithIdentifier:headCellIdentifier];
        if (headcell == nil) {
            headcell = [[[UserALLBuyHeadTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:headCellIdentifier]autorelease];
            headcell.accessoryType = UITableViewCellAccessoryNone;

        }
        [headcell setCellInfo:nil]; 
        return headcell;
    }
    if (indexPath.row == 1) {
        UserAllBuyMiddleTableViewCell *middleCell = [tableView dequeueReusableCellWithIdentifier:midlleCellIdentifier];
        if (middleCell == nil) {
            middleCell = [[[UserAllBuyMiddleTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:midlleCellIdentifier]autorelease];
            middleCell.accessoryType = UITableViewCellAccessoryNone;

        }
        [middleCell setMiddleCellInfo:nil];
        return middleCell;
    }
    
    if (indexPath.row == 2) {
        UserAllBuyInfoTableViewCell *buyInfoCell = [tableView dequeueReusableCellWithIdentifier:buyInfoCellIdentifier];
        if (buyInfoCell == nil) {
            buyInfoCell = [[[UserAllBuyInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:midlleCellIdentifier]autorelease];
            buyInfoCell.accessoryType = UITableViewCellAccessoryNone;

        }
        [buyInfoCell setMiddleCellInfo:nil];
        return buyInfoCell;
    }
    return nil;
}



- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
